Tiertex
GBC Games
Music Hacking
Documentation

-INTRODUCTION-
This document will explain how to hack the music in all of Tiertex's "more recent" Game Boy Color games (NOT the older ones like Toy Story 2, there's a list of the games supported right after this)
First, here's everything you'll need:
•	A Midi Editor (Recommended: FL Studio)
•	A Hex Editor
•	Mark Ortiz's Source Files
•	A Clean ROM of the Game
Let's get started.

-GAMES SUPPORTED-
•	Super-X (?)
•	Robot Wars: Metal Mayhem
•	Rocket Power: Getting Air
•	Noddy and the Birthday Party
•	Bob the Builder: Fix it Fun!
•	F1 Championship Season 2000
•	Rugrats: Totally Angelica
•	Tweenies: Doodles' Bones
•	Stuart Little: The Journey Home
•	Toy Story Racer
...Yeah.

-USEFUL INFORMATION-
MIDI Mapping:
PULSE:
Bright Acoustic Piano: Square Wave 12% (1)
Electric Piano 1: Square Wave 12% (2)
Clavi: Square Wave 12% (3)
Electric Piano 2: Square Wave 25%
Celesta: Square 25% w/ Sustain & Effect
Honky Tonk Piano: Square Wave 50% (1)
Harpsichord: Square Wave 50% (2)
Marimba: Square 50% w/ Effect
WAVES:
Tubular Bells: Wave 1
Xylophone: Wave 2

-GETTING STARTED-
Alright, so you got everything you need? No?
Oh yeah, you have to get Mark Ortiz's source files.
Download it here:
https://dl.dropboxusercontent.com/u/57171721/Completed%20and%20Released.zip
Without it, you won't be able to do anything.
Now that you have it, extract the files to a folder.
Inside the folder, you should have these folders:

the names of the folders should be easy to associate with the games above.
(Some of these are from GBA games, and not GB/GBC, which is why some of them are not on the list above)
For this tutorial, I'm going to use Stuart Little.
Inside a game folder, you should have something like this:

You won't be using a lot of these stuff, but don't delete them. You'll only need to use Compile.bat and the MIDIs inside the folder Midifiles.
And, it's optional, but if you don't like the wave samples used in the games, you can change them on the folder Samples (both of the waves used for music are labeled wave1.wav and wave2.wav respectively), I suggest editing them with OpenMPT or Audacity, they must have the same file size or else it won't work.

-PREPARING A MIDI-
Okay, now you should get a MIDI of the music you want to hack into the game (or make the MIDI yourself) and open it in a MIDI Editor.
Please use very very simple MIDIs, obviously you must know the Game Boy has 2 pulse channels, a wave channel and a noise channel, right? So you must keep 4 channels in a MIDI. Just edit it around, delete useless tracks, until you get something like this:

(note: this is a MIDI already from the actual game)
Now the job isn't finished yet. In order for the conversion to work, you must have to change the channel of a track to one of these:
Channel 1 = Pulse 1
Channel 2 = Pulse 2
Channel 3 = Wave
Channel 4 = Noise (Drums)
Usually the drum channel in the MIDI is 10, still you'll have to put it on Channel 4 for it to work.
To get the correct waves and instruments, refer to the Useful Information part above.
(If using FL Studio, to change the instrument of a track you'll probably need to click record, then click "play" and while the record counter ticks, rapidly change the instrument.)
If you play the result, you'll probably get an awful sounding song, but that's about to change. Export the MIDI to a file, and then move it to the Midifiles folder of the game.

-COMPILING AND TESTING-
This might be one of the most tricky parts of doing this. Before running the Compile.bat command, you must make it so your MIDI replaces a MIDI already in the folder.

Those are the MIDIs in the Stuart Little folder (.wrk files are useless since they're just Cakewalk projects and are not used)
Before replacing a MIDI in the folder, make a backup of it. Just do it. For example, if replacing the Title Screen music (SL_T.mid) copy that file first, and paste in the same folder, and rename it to something like SL_T2.mid or anything.
BUT FIRST, SOMETHING VERY IMPORTANT
The file sizes. The file containing all of the game music (for Stuart Little, size varies in other games) must be around 47 KBs, or else it won't work, so, you must know what MIDI you're using and replacing, always replace MIDIs that have the file size next to the MIDI you made.
This is all we can do for now, until research goes on, it could change, and we might be able to replace all of the music files, but for now, this is just for fun and listening and stuff.
After you replaced your MIDI, hit Compile.bat and wait a little.
Then go to the folder Output.

there might also be a .poo file which is just a backup of the .pool file that should be in there, you won't need it. All you'll need is the .pool file generated, in this case, StuTunes.pool.
Now you should open that file in an hex editor.
You should also get your clean copy of your game, and open it on the hex editor too.

you should have something like that on the .pool file. The beginning of it will be useful to find the music offset in the ROM. Copy some of the first line, go to the ROM, hit Ctrl+F (if the hex editor you're using is capable of finding text/hex values) and paste the beginning of the pool file, then hit enter.

you should find the music offset in your ROM quickly, which is located after various "ÿ" (probably unused ROM space)
Now return to the .pool file, hit Ctrl+A to select everything, then copy it.
Return to the ROM, and paste the contents from the .pool file exactly on the first character in the music offset. (In this case, the "x") 
(note that some hex editors might just paste it, and keep the original data after the pasted value, you have to replace the music offset, and not add to it.)
After you pasted it, if the .pool file is smaller than it should be, you should still see some data after the pasted text, if it's bigger or in the correct size, you might see more "ÿ"s again.
After doing all this, Save the ROM AS a new file (so if you screw up you still have the original ROM)
Then you should test the ROM, which might contain a few bugs, some levels where the music played is the wrong one, some places that don't play music at all, you'll have to find the inserted music yourself... for now.
And that's it.
Oh yeah! I almost forgot. If you just use the MIDI you have, the music won't actually loop in-game, it will play and then stop. In the next part we'll learn on how to make music loop.

-LOOPING-
To make a MIDI loop, it's simple, you have to open the MIDI in a MIDI editor that allows you to properly edit events. "MIDIEditor" is an example of it.
Open up your MIDI, and add this to the "Control" area.

Put it in the very beginning of the MIDI, or in the part where the song should loop.
Then you go to the end of the MIDI, and add another event, this time with this controller:

If you did everything correctly the music will now loop when you compile it into a .pool file.

This is all currently known about Tiertex's music system, if you are interested in researching about it too, don't hesitate in helping out with your knowledge!

-CREDITS-
Lu9 - Hacking Discovery/Document Writer
Mark Ortiz and Tiertex - The Music and the Games
MusyX Audio Tools - The System used by Tiertex